<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>pg</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_1726">&nbsp;</a>NAME</h4><blockquote>
pg - file perusal filter for soft-copy terminals (<b><a href="intro.html#tag_001_003_003">LEGACY</a></b>)
</blockquote><h4><a name = "tag_001_014_1727">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

pg<b>[</b>-<i>number</i><b>][</b>-cefns<b>][</b>-p <i>string</i><b>][</b>+<i>linenumber</i><b>][</b>+/<i>re</i>/<b>][</b><i>file</i>...<b>]</b>
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_1728">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>pg</i>
utility is a filter that allows the examination of the named
<i>file</i>
or files one screenful
at a time on a soft-copy terminal.
Each screenful is followed by a prompt.
If the user types a
carriage-return character,
another page is displayed;
other possibilities are enumerated in the EXTENDED DESCRIPTION
section.
<p>
If the standard output is not a terminal,
<i>pg</i>
ignores all options and writes the input files to standard output,
like the
<i><a href="cat.html">cat</a></i>
utility,
except that a header is written before each file (if there is
more than one).
</blockquote><h4><a name = "tag_001_014_1729">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>pg</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> ,
except that the
<i>-number</i>
option takes a multi-digit value and the
<i>+linenumber</i>
and /<i>re</i>/
options take a leading plus sign instead of minus.
The following options are supported
when standard input is a terminal:
<p>
<dl compact>

<dt>-<i>number</i><dd>
Change window size.
The
<i>number</i>
argument is a positive integer specifying the size (in lines)
of the window that
<i>pg</i>
is to use instead of the default.
(The default size is determined by the
<i>LINES</i>
environment variable.
If
<i>LINES</i>
is unset or null, a terminal-specific default size is used; the
<i>TERM</i>
environment variable may affect the determination of the
terminal-specific default size.
The default is typically one less than the number of lines
in the terminal window.)

<dt><b>-p&nbsp;</b><i>string</i>
<dd>
Use
<i>string</i>
as the prompt.
If the prompt string contains a
<b>%d</b>,
the first occurrence of
<b>%d</b>
in the prompt will be replaced
by the current page number when the prompt is issued.
The default prompt string is ":".

<dt><b>-c</b>
<dd>Home the cursor and clear the screen before displaying each page.
This option is ignored if the terminal does not support this.

<dt><b>-e</b>
<dd>Do not pause at the end of each file;
see the EXTENDED DESCRIPTION section.

<dt><b>-f</b>
<dd>Inhibit line splitting.
Normally,
<i>pg</i>
splits lines longer than the screen width,
but some sequences of characters
in the text being displayed
(for example, escape sequences for underlining)
generate undesirable results.

<dt><b>-n</b>
<dd>Cause an automatic end-of-command as soon as a command letter is entered.
Normally, commands must be terminated by a
newline
character.
The
<b>-n</b>
option is not supported on certain block-mode terminals.
If
<i>pg</i>
is being used on such terminal,
the
<b>-n</b>
option will be silently ignored
and the terminating
newline character
will be required to complete a command.

<dt><b>-s</b>
<dd>Write all messages and prompts in standout
mode (usually inverse video) if the terminal supports this.

<dt>+<i>linenumber</i><dd>
Start up at
<i>linenumber</i>.

<dt>+/<i>re</i>/<dd>Start up at the first line matching
the basic regular expression
<i>re</i>.

</dl>
</blockquote><h4><a name = "tag_001_014_1730">&nbsp;</a>OPERANDS</h4><blockquote>
The following operands are supported:
<dl compact>

<dt><i>file</i><dd>A pathname of a text file to be displayed.
If no
<i>file</i>
is given, or if it is
-, the standard input is read.

</dl>
</blockquote><h4><a name = "tag_001_014_1731">&nbsp;</a>STDIN</h4><blockquote>
The standard input is a text file that is used if no
<i>file</i>
operand is given, or if it is -.
</blockquote><h4><a name = "tag_001_014_1732">&nbsp;</a>INPUT FILES</h4><blockquote>
The input file named by the
<i>file</i>
operand is a text file.
</blockquote><h4><a name = "tag_001_014_1733">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>pg</i>:
<dl compact>

<dt><i>COLUMNS</i><dd>
Determine the horizontal screen size.
If unset or null, use the value of
<i>TERM ,
</i>the window size, baud rate, or some combination of these,
to indicate the terminal type for the screen size calculation.

<dt><i>LINES</i><dd>Determine the number of lines to be displayed on the screen.
If unset or null, use the value of
<i>TERM ,
</i>the window size, baud rate, or some combination of these,
to indicate the terminal type for the screen size calculation.

<dt><i>SHELL</i><dd>Determine the name of the command interpreter executed for a
!command.

<dt><i>TERM</i><dd>Determine terminal attributes.
Optionally attempt to search a system-dependent database,
keyed on the value of the
<i>TERM</i>
environment variable.
If no information is available, a terminal incapable of
cursor-addressable movement is assumed.

</dl>
<p>
The following environment variables may affect the execution of
<i>pg</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_COLLATE</i><dd>
Determine the locale for the
behaviour of ranges, equivalence classes
and multi-character collating elements
within regular expressions.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments and input files) and
the behaviour of character classes within regular expressions.

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error,
and informative messages written to standard output.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
</dl>
</blockquote><h4><a name = "tag_001_014_1734">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
During the writing of characters to the standard output,
<i>pg</i>
catches SIGINT and SIGQUIT, returning the user to the prompt.
When waiting at the prompt,
<i>pg</i>
takes the default action on SIGINT and SIGQUIT.
The default actions are taken for all other signals.
</blockquote><h4><a name = "tag_001_014_1735">&nbsp;</a>STDOUT</h4><blockquote>
The standard output is a display of the input files,
with prompts interspersed.
When standard output is not associated with a terminal,
it consists of the contents of the input files, separated
by the following lines, if there is more than one input file:
<p><code>
<tt>"::::::::::::::\n%s\n::::::::::::::\n"</tt>, &lt;<i>pathname</i>&gt;
</code>
</blockquote><h4><a name = "tag_001_014_1736">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_001_014_1737">&nbsp;</a>OUTPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1738">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
The responses that can be typed when
<i>pg</i>
pauses can be divided
into three categories: those causing further perusal, those that
search and those that modify the perusal environment.
<p>
Commands that cause further perusal normally take a preceding
address; an optionally signed number indicating the point from
which further text should be displayed.
This address is
interpreted in either pages or lines depending on the command.
A signed address specifies a point relative to the current page or
line, and an unsigned address specifies an address relative to the
beginning of the file.
Each command has a default address that is
used if none is provided.
<p>
The perusal commands and their defaults are as follows:
<dl compact>

<dt>(+1)&lt;newline&gt;&nbsp;or&nbsp;&lt;space&gt;<dd>
Display one page.
The address is specified in number of pages.

<dt>(+1)<b>l</b><dd>With a relative address,
simulate scrolling the screen, forward or backward, by
the number of lines specified.
With an absolute address,
print a screenful
beginning at the specified line.

<dt>(+1)<b>d&nbsp;</b>or&nbsp;&lt;control&gt;-D<dd>
Simulate scrolling half a screen forward or backward.

</dl>
<p>
The following perusal commands take no address:
<dl compact>

<dt><b>.&nbsp;</b>or&nbsp;&lt;control&gt;-L<dd>
Redisplay the current page of text.

<dt><b>$</b><dd>Display the last windowful in the file.

</dl>
<p>
The following commands are available for searching for text patterns
in the text.
Basic regular expression syntax is used in patterns.
The
<i>re</i>s
must always be terminated by a
newline character,
even if the
<b>-n</b>
option is specified.
<dl compact>

<dt><i>i</i><b>/</b><i>re</i><b>/</b><dd>Search forwards for the
<i>i</i>th
occurrence of
<i>re</i>
(default
<i>i</i>=1).
Searching begins immediately after the current page and continues to the
end of the current file, without wrap-around.

<dt><i>i</i>^<i>re</i>^<dd>
<dt><i>i</i>?<i>re</i>?<dd>Search backwards for the
<i>i</i>th
occurrence of
<i>re</i>
(default
<i>i</i>=1).
Searching begins immediately before the current page
and continues to the beginning of the current file, without
wrap-around.

</dl>
<p>
After searching,
<i>pg</i>
will normally display the line found at the top of the screen.
This can be modified by appending
<b>m</b>
or
<b>b</b>
to the search
command to leave the line found in the middle or at the bottom of
the window from now on.
The suffix
<b>t</b>
can be used to restore the original situation.
<p>
If the standard output is not a terminal device,
<i>pg</i>
always exits when
it reaches end-of-file on the last file in its argument list.
Otherwise, for all
files but the last,
<i>pg</i>
prompts with an indication
that it has reached the end-of-file, along with the name of
the next file;
when
<b>-e</b>
is used, the end-of-file prompt is bypassed
and the prompt indicates the name of the next file.
For the last file specified, or for the
standard input if no file is specified,
<i>pg</i>
prompts indicating end-of-file (if
<b>-e</b>
is not used), and accepts additional commands.
If the next command specifies forward scrolling,
<i>pg</i>
exits.
If the
<b>-e</b>
option is specified,
<i>pg</i>
exits immediately after writing the last line of the last file.
<br>
<p>
The user of
<i>pg</i>
can modify the environment of perusal with the
following commands:
<dl compact>

<dt><i>i</i><b>n</b><dd>Begin perusing the
<i>i</i>th
next file in the command line.
The
<i>i</i>
is an unsigned number; default value is 1.

<dt><i>i</i><b>p</b><dd>Begin perusing the
<i>i</i>th
previous file in the command line.
The
<i>i</i>
is an unsigned number; default is 1.

<dt><i>i</i><b>w</b><dd>Display another window of text.
If
<i>i</i>
is present, set the window size to
<i>i</i>.

<dt><b>s</b><i>&nbsp;&nbsp;filename</i><dd>
Save the input in the file named
<i>filename</i>.
Only the current file being perused is saved.
The
blank-character-separation
between the
<b>s</b>
and
<i>filename</i>
is optional.
This command must always be terminated by a
newline character,
even if the
<b>-n</b>
option is specified.

<dt><b>h</b><dd>Help by displaying an abbreviated summary of available commands.

<dt><b>q&nbsp;</b>or&nbsp;<b>Q</b><dd>Quit
<i>pg</i>.

<dt><b>!</b><i>command</i><dd>
Pass the argument
<i>command</i>
to the command interpreter, whose name is
taken from the
<i>SHELL</i>
environment variable.
If
<i>SHELL</i>
is unset or null,
<i><a href="sh.html">sh</a></i>
is used as the default
command interpreter.
This command must always be terminated by a
newline character,
even if the
<b>-n</b>
option is specified.

</dl>
<p>
At any time when output is being sent to the terminal, receipt of a
quit or interrupt signal causes
<i>pg</i>
to stop sending output and to display the prompt.
The user may then enter one of the above commands in the normal manner.
Unfortunately, some output is lost when this is done, due to the fact
that any characters waiting in the terminal's output queue are flushed
when the signal occurs.
</blockquote><h4><a name = "tag_001_014_1739">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>Successful completion.

<dt>&gt;0<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_001_014_1740">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_1741">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
This utility is different from previous paginators
in that it allows the user to back up
and review something that has already passed.
The method for doing this is explained in the
EXTENDED DESCRIPTION section.
<p>
While waiting for terminal input,
<i>pg</i>
responds to
SIGINT
and
SIGQUIT
signals by terminating execution.
Between prompts, however, these signals interrupt
<i>pg</i>'s
current task and place the user in prompt mode.
These signals should be used with caution when input is being read from
a pipe, since an interrupt is likely to terminate the other
commands in the pipeline.
<p>
Use the
<b>$</b>
command with caution when the input is a pipe.
<p>
If terminal tabs are not set every eight column positions,
undesirable results may occur.
<p>
When
<i>pg</i>
is used as a filter with another command that changes the terminal
I/O options, terminal settings might not be restored correctly.
<p>
Applications should migrate to the
<i><a href="more.html">more</a></i>
utility.
</blockquote><h4><a name = "tag_001_014_1742">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1743">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_1744">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="more.html">more</a></i>,
the <b>XBD</b> specification, <a href="../xbd/re.html#tag_007_003"><b>Basic Regular Expressions</b>&nbsp;</a> ,
the <b>XBD</b> specification, <a href="../xbd/termios.html"><b>General Terminal Interface</b>&nbsp;</a> .
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
